/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.axiom.controller;

import com.axiom.persistence.user_detail_persist;
import com.axiom.vo.user_detail;

/**
 *
 * @author Shuhail
 */
public class user_details_controller {
    
    public static user_details_controller getInstance() {
        
        return new user_details_controller();
    }
    
    public boolean insertFresh(user_detail user) {
        
        return user_detail_persist.getInstance().insertFresh(user);
    }
    
    
    public user_detail getDetailsForAuthentication(String name) {
        
        return user_detail_persist.getInstance().fetchForAuthentication(name);
    }
    
    public user_detail authenticateLogin(String name ,String pass) {
        
        user_detail detail = this.getDetailsForAuthentication(name);
        if(detail==null) {
            
            System.out.println("Not A Valid User");
            return null;
        }
        //Here password is case sensitive whereas userid is not
        if(detail.getUser_id().equalsIgnoreCase(name) && detail.getPass().equals(pass)) {
            
            System.out.println("Valid User... Authenticated");
            return detail;
        }
        
        return null;
        
        
        
    }
    
    
}
